<?php /* Smarty version Smarty-3.0.8, created on 2014-11-06 16:09:46
         compiled from "G:\xmap\htdocs\tucao/tpl\main_index.html" */ ?>
<?php /*%%SmartyHeaderCode:16437545b2cca0722c4-98048504%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '98d3b8d15e02fb626afdbc7894f92d73ebb4360f' => 
    array (
      0 => 'G:\\xmap\\htdocs\\tucao/tpl\\main_index.html',
      1 => 1415261248,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '16437545b2cca0722c4-98048504',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
)); /*/%%SmartyHeaderCode%%*/?>
<!DOCTYPE html>
<html>
	<head>

	    <title>Tucao</title>
	    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
	    <link rel="stylesheet" href="tpl/css/app.css">
	    <link rel="stylesheet" href="tpl/css/tucao.css">
	    <link rel="stylesheet" href="tpl/css/tucao-ui.css">
	</head>

  	<body class="s-theme-a">

		<?php $_template = new Smarty_Internal_Template("tpl/home.html", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>
		<?php $_template = new Smarty_Internal_Template("tpl/search.html", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>
		<?php $_template = new Smarty_Internal_Template("tpl/tucao.html", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>
		<?php $_template = new Smarty_Internal_Template("tpl/create_tc.html", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>
		<?php $_template = new Smarty_Internal_Template("tpl/tc_content.html", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>
		<?php $_template = new Smarty_Internal_Template("tpl/publish.html", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>
		<?php $_template = new Smarty_Internal_Template("tpl/nav.html", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>
		<?php $_template = new Smarty_Internal_Template("tpl/user.html", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>
		<?php $_template = new Smarty_Internal_Template("tpl/store.html", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>
		<?php $_template = new Smarty_Internal_Template("tpl/setting.html", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>
		<?php $_template = new Smarty_Internal_Template("tpl/us.html", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>
		<?php $_template = new Smarty_Internal_Template("tpl/message.html", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>
		<?php $_template = new Smarty_Internal_Template("tpl/login.html", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>
		<?php $_template = new Smarty_Internal_Template("tpl/register.html", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>

		<script  src="tpl/js/zepto.min.js"></script>
		<script  src="tpl/js/zepto.touch.js"></script>
		<script  src="tpl/js/function.js"></script>

		<script  src="tpl/js/app.js"></script>		
		<script  src="tpl/js/jquery-1.11.1.min.js"></script>

		<script>
		//登录
		App.controller('login', function (page) {
			this.transition = 'slide-left';
		  	$(page).on("appReady",function(){
		     	$.get( url("user","logout") );
		      	$("#j-login-username").val(kget("username"));
		  	});				
			$(page).find(".g-extra").on("tap",function(){
				App.load("register");
			});
			$(page).find("#j-login-btn").on("tap",function(){
				var username = $("#j-login-username").val();
				var pwd = $("#j-login-pwd").val();
				$.post( url("user","login"), {username:username,pwd:pwd}, function(data){
				    if(typeof(data.id) != "undefined"){
				      kset("id",data.id);
				      kset("username",data.username);
				      App.load("home");
				    }else{
				      alert(data.errmsg);
				    }						
				},"json");
			});				
		});
		//注册
		App.controller('register', function (page) {
			this.transition = 'slide-left';
			$(page).find("#j-register-btn").on("tap",function(){
				var username = $("#j-register-username").val();
				var pwd = $("#j-register-pwd").val();
				$.post( url("user","register"), {username:username,password:pwd}, function(data){
				    if(data == 1){
				    	App.load("login");
				    }else{
				      alert(data.errmsg);
				    }						
				},"json");
			});			
		});
		//导航
		App.controller('nav', function (page) {
			this.transition = 'slide-right';
			$(page).on("appReady",function(){
				$("#j-nav-username").text(kget("username"));
				if($("body").hasClass("s-theme-b")){
					$("#ctheme").attr("checked",true);
				}				
			});
			$(page).find("li").not(":nth-of-type(5)").on("tap",function(){
				$(this).addClass("f-active").siblings().removeClass("f-active");
			});
			//user
			$(page).find(".g-favicon").on("tap",function(){
				App.load("user");
			});			
			//home
			$(page).find("li:nth-of-type(1)").on("tap",function(){
				App.load("home");
			});
			//message
			$(page).find("li:nth-of-type(2)").on("tap",function(){
				App.load("message");
			});
			//store
			$(page).find("li:nth-of-type(3)").on("tap",function(){
				App.load("store");
			});
			//setting
			$(page).find("li:nth-of-type(4)").on("tap",function(){
				App.load("setting");
			});										
			//us
			$(page).find("li:nth-of-type(6)").on("tap",function(){
				App.load("us");
			});
			//login
			$(page).find("li:last-of-type").on("tap",function(){
				App.load("login");
			});
			$(page).find(".slider").on("tap",function(){
				if($("#ctheme").is(":checked")){
					$("body").removeClass("s-theme-a").addClass("s-theme-b");
				}else{
					$("body").removeClass("s-theme-b").addClass("s-theme-a");
				}
			});
		});
		//home
		App.controller('home', function (page,message) {
			this.transition = 'slide-left';
			$(page).on("appReady",function(){

				$.post( url("tucao","tucao_list"), function(data){
					for(var i=0;i<data['own'].length;i++){

						var li_own = $("<li>").data("contact",data['own'][i]).html("<span class='mask'><span>"+data['own'][i].tucao_name+"</span></span>");
						li_own.css({"background":"url("+data['own'][i].logo_addr+")"});
						li_own.on("tap",function(){
							var contact=$(this).data("contact");
							App.load("tucao",contact);
						});
						$(".m-list-group").find("li:last").before(li_own);
					}
					for(var i=0;i<data['join'].length;i++){

						var li_join = $("<li>").data("contact",data['join'][i]).html("<span class='mask'><span>"+data['join'][i].tucao_name+"</span></span>");
						li_join.css({"background":"url("+data['join'][i].logo_addr+")"});
						li_join.on("tap",function(){
							var contact=$(this).data("contact");
							App.load("tucao",contact);
						});						
						$(".m-list-group").find("li:last").before(li_join);
					}
				},"json");

				if(message.name =="undefined"){
					var li = $("<li>").data("contact",message).html("<span class='mask'><span>"+message.name+"</span></span>");
					li.css({"background":"url("+message.logo_addr+")"});
					li.on("tap",function(){
						var contact=$(this).data("contact");
						App.load("tucao",contact);
					});					
					$(".m-list-group").find("li:last").before(li);	
				}							
			});		
			$(page).find("li:last-of-type").on("tap",function(){
				App.load("create_tc");
			});			
		});
		//tucao
		App.controller('tucao', function (page,contact) {
			$(page).on("appReady",function(){
				$("#j-tucao-title").html(contact.tucao_name);
			});
		});
		//create_tc
		App.controller('create_tc', function (page) {
			this.transition = 'slide-left';

			$(page).find(".g-logo").on("tap",function(){
				$("#j-ctc-file").trigger("click")
			});
			$(page).find("#j-ctc-file").on("change",function(e){
				var file = e.target.files[0];
				if(window.FileReader){
				var reader = new FileReader();
				reader.readAsDataURL(file);
				reader.onload = (function(var_file){
				  return function(e){
				    var src = e.target.result;
				    $(".g-logo").find("img").attr("src",src);
				  }
				})(file);
				}
			});
			$(page).find("#j-ctc-btn").on("tap",function(){
				
				if(!$("#j-ctc-username").val()){
					alert("吐槽对象不能为空!");
					return;
				}
				if($("#j-ctc-file").val()){
					var names=$("#j-ctc-file").val().split(".");
					if(names[1]!="gif"&&names[1]!="GIF"&&names[1]!="jpg"&&names[1]!="JPG"&&names[1]!="png"&&names[1]!="PNG")
					{
				 		alert("logo格式必须为jpg、gif和png");
				  		return;
					}
				}
				$("#j-upform").submit();
			});						
		});	
        function showLogo(message,success){
            if(success==false)
            {
                alert(message);
            }
            else{
                alert("吐槽对象创建成功",function(){
                	App.load("home",message)
                });
            }
        }					
	    try{
	        //相当于检查session
	        $.get(url("user","is_login"),function(data){
	        	
	            if(data.errcode == "success")
	            {
	              App.restore();
	            }else{
	              App.load("login");
	            }
	        },"json");

	    }catch (err) {
	        App.load("login");
	    }

		</script>
    
	</body>
</html>